﻿//-----------------------------------------------------------------------
// <copyright file="Cart.cs" company="FER">
//     Copyright (c) All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace NMBP.Models
{
    using System.Collections.Generic;
    using NMBP.Models.Enums;

    /// <summary>
    /// Represents cart for storage of items in store
    /// </summary>
    public class Cart
    {
        /// <summary>
        /// Gets or sets Products which are currently in basket
        /// </summary>
        public List<Product> Products { get; set; }

        /// <summary>
        /// Gets or sets Customer which bought the products
        /// </summary>
        public Customer Customer { get; set; }

        /// <summary>
        /// Gets or sets total price for all products in cart
        /// </summary>
        public float TotalPrice { get; set; }

        /// <summary>
        /// Gets or sets payment method for current purchase
        /// </summary>
        public PaymentMethod PaymentMethod { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether cart was ordered
        /// </summary>
        public bool IsOrdered { get; set; }

        /// <summary>
        /// Adds product to cart
        /// </summary>
        /// <param name="product">product to be added</param>
        public void AddProductToCart(Product product)
        {
            this.Products.Add(product);
            this.TotalPrice += product.Price;
        }

        /// <summary>
        /// Removes product from cart
        /// </summary>
        /// <param name="product">Product to be removed</param>
        public void RemoveProductFromCart(Product product)
        {
            this.Products.Remove(product);
            this.TotalPrice -= product.Price;
        }
    }
}
